package cn.ad.server.web.servlet;

import cn.ad.server.web.servlet.v2.RestPathFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 
 * @deprecated 原广告请求处理Servlet框架将不推荐使用，统一采用v2包下的处理方式，请求入口参考{@link RestPathFilter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)}
 */
@Deprecated
@WebServlet("/bid/gdt.html")
public class GDTBidRequestServlet extends AbstractBidServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3652342371974024964L;

	final static Logger logger = LoggerFactory.getLogger(GDTBidRequestServlet.class);

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		try {
			request.getRequestDispatcher("/v2/bid/ch/3").forward(request, response);
			return;
			
//			String id = request.getParameter("id");
//			response.setContentType("application/x-protobuf;charset=utf-8");
//			if (StringUtils.hasText(id)) {
//
//				BidProcessor bidProcessor = SpringContextUtils.getBean(Exchange.exchangeMap.get(id),
//						BidProcessor.class);
//				GDTBidResponse bidResponse = (GDTBidResponse) bidProcessor.process(request, response);
//
////				if (bidResponse == null) {
////					response.setStatus(204);
////					return;
////				}
//
//				Codec<GDTBidResponse> gdtBidResponseCodec = ProtobufProxy.create(GDTBidResponse.class);
//				CodedOutputStream z = CodedOutputStream.newInstance(response.getOutputStream());
//
//				gdtBidResponseCodec.writeTo(bidResponse, z);
//				z.flush();
//			} else {
//				response.setStatus(400);
//			}
		} catch (Exception e) {
			logger.error("/bid/gdt.html - error", e);
		}

	}

}
